#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>
struct stu
{
	char ming[20];
	int year;
	char xuehao[20];
};
int int_com(void* p1, void* p2)
{
	return *(int*)p1 - *(int*)p2;
}
int double_com(void* p1, void* p2)
{
	return *(double*)p1 - *(double*)p2;
}
int float_com(void* p1, void* p2)
{
	return *(float*)p1 - *(float*)p2;
}
int char_com(void* p1, void* p2)
{
	return *(char*)p1 - *(char*)p2;
}
int struct_stu_com(void* p1, void* p2)
{
	return strcmp((*(struct stu*)p1).ming, (*(struct stu*)p2).ming);
}


void maopao(void* arr, size_t num, size_t size, int (*cmp)(void* p1, void* p2))
{
	int i = 0;
	int j = 0;
	char tmp;

	for (i = 0; i < num - 1; i++)
	{
		for (j = 0; j < num - i - 1; j++)
		{
			if (cmp((char*)arr + j * size, (char*)arr + (j + 1) * size) > 0)
			{
				for (int t = 0; t < size; t++)
				{
					tmp = *((char*)arr + j * size + t);
					*((char*)arr + j * size + t) = *((char*)arr + (j + 1) * size + t);
					*((char*)arr + (j + 1) * size + t) = tmp;
				}
			}
		}
	}
}

int main()
{
	struct stu arr1[5];
	for (int i = 0; i < 5; i++)
	{
		scanf("%s", &arr1[i].ming);
		scanf("%d", &arr1[i].year);
		scanf("%s", &arr1[i].xuehao);
	}
	int z = 0;
	int (*com[])(void*, void*) = { int_com, double_com, float_com, char_com, struct_stu_com};
	printf("1. int   2. double   3. float   4. char   5. struct stu\n");
	scanf("%d", &z);
	size_t num = sizeof(arr1) / sizeof(arr1[0]);

	maopao(arr1, num, sizeof(arr1[0]), com[z - 1]);
	for (int i = 0; i < num; i++)
	{
		printf("%s ", arr1[i].ming);
		printf("%d ", arr1[i].year);
		printf("%s ", arr1[i].xuehao);
		printf("\n");
	}
	return 0;
}